package com.chenfeng.ego.controller;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.chenfeng.ego.service.PicService;

@Controller
public class PciUploadController
{
	//图片上传的处理
	@Resource
	PicService picService;
	@RequestMapping("pic/upload")
	@ResponseBody
	public Map<String,Object> uploadPic(MultipartFile uploadFile)
	{
		
		Map map = new HashMap<String,Object>();
		try
		{
			map = picService.upload(uploadFile);
		} catch (NumberFormatException | IOException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
			map.put("error", 1);
			map.put("message", "图片上传失败");
		}
		return map;
	}
}
